#ifndef __CONFIG__MODULE__H__
#define __CONFIG__MODULE__H__
#include "PluginModule/IConfigModule.h"
#include "PluginModule/ILogModule.h"
#include "Protocol/Protocol.h"

namespace FragrantGrass
{
	class ConfigModule : public IConfigModule
	{
	public:
		struct ConfigData
		{
			FileParseType type;
			std::string name;
			FILE_PARSE_FUNCTION function;
			bool existed;
		};
		typedef std::map<FileParseType, ConfigData> FileParserMap;

	public:
		ConfigModule(IPluginManager* p);
		virtual ~ConfigModule();

		virtual bool Init() override;
		virtual bool AfterInit() override;
		virtual bool Finalize() override;

		virtual void SetConfigPath(const std::string& strPath);
		virtual void* GetConfigDatas(FileParseType type);

	protected:
		bool GetFileContent(const std::string& strFileName, std::string& strContent);
		void RegisterFileParser(FileParseType type, FILE_PARSE_FUNCTION func,const std::string& name);
		void* FileParser_ServerDatas(const std::string& strFileName, std::string& strContent);

	private:
		std::string m_strConfigPath;
		FileParserMap m_fileParserMap;
		ILogModule* m_pkLogModule;
		Protocol::ServerInfoReportList m_ServerInfoReportList;
	};
}
#endif//__CONFIG__MODULE__H__